//
//  PrefixHeader.pch
//  ZDMiaoBo
//
//  Created by 张东 on 16/9/29.
//  Copyright © 2016年 张东. All rights reserved.


#import "AFHTTPSessionManager+POST.h"
#import "NSString+MD5.h"
#import "ZHRTBasicMethod.h"

@implementation AFHTTPSessionManager (POST)

+ (NSURLSessionDataTask *)POSTWithParams:(NSDictionary *)params success:(AFSuccessBlock)successBlock failure:(AFFailureBlock)failureBlock {
    {
        AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        
        /*
         系统唯一标识
         是什么设备：iPad还是iPhone等
         iOS版本号
         系统名称
         
         [[UIDevice currentDevice] uniqueIdentifier],
         [[UIDevice currentDevice] localizedModel],
         [[UIDevice currentDevice] systemVersion],
         [[UIDevice currentDevice] systemName],
         [[UIDevice currentDevice] model]];
         */
        NSString * uid;
        NSString * token;
        NSUserDefaults * df = [NSUserDefaults standardUserDefaults];
        if ([df objectForKey:@"uid"]) {
            uid = [df objectForKey:@"uid"];
            
        }else {
            uid = @"0";
        }
        if ([df objectForKey:@"token"]) {
            token = [df objectForKey:@"token"];
        }else {
            token = @"0";
        }
        
        manager.requestSerializer=[AFJSONRequestSerializer serializer];
        NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
        NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
        
        NSDictionary * hard =  @{@"token":token,
                                 @"mode":@"iOS",
                                 @"device": @"2.0",
                                 @"version":app_Version,
                                 @"uid":@"285",
                                 };
//22928   75
        
//        张路路 为绑卡 91
        NSDictionary * key = @{@"header":hard, @"param":params};
    
        NSString * str = [NSString stringWithFormat:@"zhrt2016%@",[ZHRTBasicMethod DataTOjsonString:key]];
        NSArray * arry = [str componentsSeparatedByString:@"\n"];
        NSString * ss = [arry componentsJoinedByString:@""];
        
        
        NSArray * arry1 = [ss componentsSeparatedByString:@" "];
        NSString * ss1 = [arry1 componentsJoinedByString:@""];
        
        
        NSString * strMd5 = [ss1 md5String];
        NSDictionary * keys = @{@"jsonSalt":key, @"md5Key":strMd5};
    
        return  [manager POST:KBaseUrl parameters:keys success:successBlock failure:failureBlock];
        
        
    }
}
@end
